package cn.zdm.designpattern.strategy;

/**
 * copyright (C), 2020, 北京同创永益科技发展有限公司
 *
 * @author ZhaoDeman
 * @version 1.0.0
 * <author>                <time>                  <version>                   <description>
 * ZhaoDeman        2020/12/4 13:30                 1.0
 * @program designpattern
 * @description
 * @create 2020/12/4 13:30
 */
public class Context {
    private Strategy strategy;

    public Context(String type) {
        switch (type) {
            case "add":
                strategy = new OperationAdd();
                break;
            case "sub":
                strategy = new SubStrategy();
                break;
            case "multiply":
                strategy = new OperationMultiply();
                break;
            default:
                break;
        }
    }

    /***
     *
     * @param
     * @date 2020/12/4 13:59
     * @return void
     */
    public void calc(int num1, int num2) {
        System.out.println(strategy.calc(num1, num2));
    }
}
